<?php 
include_once "functions.php";


//check for user logged in or not
$user = new User();

if ($user->get_session()):

header("location:home.php");
endif;

if( $_SERVER["REQUEST_METHOD"] == "POST"):

$register = $user->registration_user($_POST['fname'], $_POST['mname'], $_POST['lname'], $_POST['gender'],	
								 $_POST['birthdate'], $_POST['address'], $_POST['cp'], $_POST['phone'],
								 $_POST['email'], $_POST['username'], $_POST['password']);

	if ($register):
	echo 'Regis                                                                                                                                                                         tration successful <a href="login.php">Click here</a> to login';
	elseif($fname):
                    
                        $f1_space = "1"; 
                        if (((strlen($fname) >= "2")) and (!(preg_match("/[^a-zA-Z\s-]/", $fname)))):
                        
                        $f1 = '1';
                        
                        else:
                        echo "<font color='#C00' size='1'> Your first name must be at least 2 letters long</font>";
                    endif;
                    //error handler
                    if ($f1_space == ''):
                    echo "<font color='#C00' size='1'> This information is required</font>";
					endif;	
	echo 'Registration failed. Email or Username already exits please try again';
	endif;
	
endif;

?>
